import request from '@/utils/request'
import { qualityApiUrl } from '@/api/config.js'

// 风险跟踪 //
/**
 * 查询风险上报列表-所有的项目所有的风险上报列表
 * @param data
 */
export function getList(data) {
  return request({
    url: qualityApiUrl + '/quality/riskTrack/queryDetails',
    method: 'post',
    data: data
  })
}
/**
 * 历史版本
 * @param id
 */ 
export function getHistory(id) {
  return request({
    url: qualityApiUrl + `/quality/riskTrack/getHis/${id}`,
    method: 'get',
  })
}
/**
 * 查询单个风险跟踪
 * @param id
 */ 
export function getDetail(id, historyId = '-1') {
    return request({
      url: qualityApiUrl + `/quality/riskTrack/${id}/${historyId}`,
      method: 'get',
    })
  }
/**
 * 调整项目跟踪
 * @param data
 */
export function adjustment(data) {
  return request({
    url: qualityApiUrl + '/quality/riskTrack/adjustment',
    method: 'post',
    data: data
  })
}
/**
 * 业务代办风险处理人处理风险跟踪，增加跟踪计划
 * @param data
 */
export function handleCreate(data) {
  return request({
    url: qualityApiUrl + '/quality/riskTrack/create',
    method: 'post',
    data: data
  })
}
/**
 * 修改项目跟踪
 * @param data
 */
export function updatePost(data) {
    return request({
      url: qualityApiUrl + '/quality/riskTrack/update',
      method: 'post',
      data: data
    })
  }
/**
 * 统计总数
 * @param data
 */
export function count(data) {
    return request({
      url: qualityApiUrl + '/quality/riskTrack/statistics',
      method: 'post',
      data: data
    })
  }
  /**
 * 风险方案处理人（业务代办）
 * @param id
 */
export function businessToDo(id) {
  return request({
    url: qualityApiUrl + `/quality/riskTrack/${id}`,
    method: 'get',
  })
}
/**
 * 导出接口
 * @param data
 */
export function excels(id) {
  return request({
    url: qualityApiUrl + `/quality/riskTrack/excels/${id}`,
    method: 'get',
    responseType: 'blob'
  })
}
export const riskTracking = {
    getList,
    count,
    getHistory,
    getDetail,
    adjustment,
    handleCreate,
    updatePost,
    businessToDo,
    excels
  }